package main

import (
	"fmt"

	"golang.org/x/net/websocket"
)

func add(param string) {
	ws, err := websocket.Dial("ws://127.0.0.1:8888/add", "", "http://127.0.0.1:8888/")
	if err != nil {
		fmt.Println(err)
	}

	defer ws.Close()

	sendMsg := []byte(param)
	_, err = ws.Write(sendMsg)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("Send: %s\n", string(sendMsg))

	msg := make([]byte, 512)
	m, err := ws.Read(msg)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("Receive: %s\n", msg[:m])
}

func main() {
	add("梦想小镇")
}
